import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  server: {
    host: '0.0.0.0',
    port: 5133,
    open: true,
    proxy: {
      "/api": {
        target: "https://mock.mengxuegu.com/mock/682d425887d58f6835383b93/examplevuethree", // easymock
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '') // 去除路径前缀
      }
    }
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, './src')
    }
  }
})